import {useNavigate, useParams, useSearchParams} from "react-router-dom";

function withHoc (WrapperComponent) {
    return function (props) {
        // 获取导航，可以使用导航的方法进行跳转
        const navigate = useNavigate();
        // 获取path路径上的参数
        const params = useParams();
        // 获取问号后的参数
        const [searchParams] = useSearchParams();
        console.log('searchParams', searchParams)
        const hoc = {
            params, navigate, searchParams
        }
        console.log(hoc);
        return <WrapperComponent {...props} hoc={hoc}/>
    };
}

export default withHoc;